package com.nhatviet.webservice.helpers;

import java.util.Date;

public final class FourSquareVenueService
{
	/**
	 * URL common
	 */
	public static final String	URL				= "https://api.foursquare.com/v2/";
	public static final String	OAUTH_TOKEN		= "KCLSSXVHBEEBTPKLK4MOAYC1RRBXADV3ST4CAG0SLOXNND3U";
	/**
	 * Format receiving file
	 */
	public static final String	FORMAT_XML		= "rest";
	public static final String	FORMAT_JSONP	= "json";
	public static final String	FORMAT_JSON		= "json&nojsoncallback=1";
	public static final String	FORMAT_PHP		= "php_serial";

	/**
	 * Get URL
	 * 
	 * @param groupStr
	 *            the group API name
	 * @param methodStr
	 *            method name
	 * @param latitudeStr
	 *            geo latitude
	 * @param longitudeStr
	 *            geo longitude
	 * @return URL string
	 */
	public static String getURL(String groupStr, String methodStr, String latitudeStr, String longitudeStr)
	{
		return URL + groupStr + "/" + methodStr + "?" + "ll=" + latitudeStr
				+ "," + longitudeStr + "&oauth_token=" + OAUTH_TOKEN + "&v="
				+ getToday();
		
	}

	public static String getURL(String groupStr, String methodStr, String latitudeStr, String longitudeStr, String dayStr)
	{
		return URL + groupStr + "/" + methodStr + "?" + "ll=" + latitudeStr
				+ "," + longitudeStr + "&oauth_token=" + OAUTH_TOKEN + "&v="
				+ dayStr;
	}
	
	public static String getToday()
	{
		String dayStr = "";
		Date today = new Date();		
		int year = today.getYear() + 1900;
		int month = today.getMonth() + 1;
		int date = today.getDate();
		dayStr += "" + year + (month < 10 ? "0" + month : month) +(date < 10 ? "0" + date : date); 
		return dayStr;
	}
}
